package personal.persistance.model;

import personal.persistance.AbstractJdbcModel;
import personal.persistance.mapper.MapperConstant;

/**
 *
 * @author LocNguyen
 */
public class Image extends AbstractJdbcModel<Integer> {
    private String url;
    private String comment;
    private int album; // Each image should have it's own album

    public Image() {
    }

    public Image(String url, String comment) {
        this.url = url;
        this.comment = comment;
    }

    public int getAlbum() {
        return album;
    }

    public void setAlbum(int album) {
        this.album = album;
    }
    
    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

   @Override
    public String getTableName() {
        return MapperConstant.DB_NAME
                + ".image";
    }

    @Override
    public boolean isIdAutoIncrement() {
        return true;
    }

    @Override
    public String[] getColumnNames() {
        return new String[]{
                    "URL",
                    "COMMENT"
                };
    }

    @Override
    public Object[] getColumnValues() {
        return new Object[]{
                    url,
                    comment
                };
    }

    @Override
    public void setColumnValues(Object[] values) {
        try {
            url = values[0].toString();
            if (values.length > 1 && values[1] != null)
                comment = values[1].toString();
        } catch (Exception e) {
            throw new IllegalArgumentException(e);
        }
    }
}

